package cn.com.nes.site.controller.monitor;

import cn.com.nes.site.entity.PageData;
import cn.com.nes.site.entity.vo.fault.FaultVo;
import cn.com.nes.site.entity.vo.monitor.BrandVo;
import cn.com.nes.site.entity.vo.monitor.GetEquipmentInfoOperationConditionHistoryVo;
import cn.com.nes.site.entity.vo.monitor.SavePersonalProtocolDataToMemoryVo;
import cn.com.nes.site.service.monitor.EquipmentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@Controller
@RequestMapping("/v2/equipmentInfo")
public class EquipmentInfoController {

    @Autowired
    private EquipmentService equipmentService;

    @RequestMapping(value = "getBrand", method = RequestMethod.POST)
    @ResponseBody
    public PageData getBrand(@RequestBody BrandVo vo)  throws Exception{
        List<Map<String, Object>> list = equipmentService.getBrand(vo);
        return PageData.ok(list, true);
    }

    @RequestMapping(value = "getHistoricalFaultSbList", method = RequestMethod.POST)
    @ResponseBody
    public PageData getHistoricalFaultSbList(@RequestBody FaultVo vo)  throws Exception{
        // TODO: 2024/3/7 如何使用userInfo判断是否为代理商
        return equipmentService.getHistoricalFaultSbList(vo);
    }

    /**
     * 保存个人协议数据项 记忆功能
     * @param vo
     * @return
     */
    @PostMapping("/savePersonalProtocolDataToMemory")
    @ResponseBody
    public PageData savePersonalProtocolDataToMemory(SavePersonalProtocolDataToMemoryVo vo) {
        return equipmentService.savePersonalProtocolDataToMemory(vo);
    }

    /**
     * 获取该设备历史运行情况数据
     * @param vo
     * @return
     */
    @PostMapping("/getEquipmentInfoOperationConditionHistory")
    @ResponseBody
    public PageData getEquipmentInfoOperationConditionHistory(GetEquipmentInfoOperationConditionHistoryVo vo){
        return equipmentService.getEquipmentInfoOperationConditionHistory(vo);
    }

}
